Replace text by Object

Hi,

 

I want to replace a particular word by one object text.

I want to perform following steps:

     1. Copy one object text & store it to program memory

     2. Loop through the all object text and find the particular word say 'test'

     3. Now replace all the 'test' words found by a object text copied to program memory in step 1.

I couldn't find the function to copy the object text.

Please help me with this.

 

Thanks

-Amol


Amol_S - Thu Jul 06 22:20:11 EDT 2017

Re: Replace text by Object
strathglass - Fri Jul 07 09:23:00 EDT 2017

Object o=current
string oTxt=o."Object Text"

Of course the work is easy if it is just plain text.

But you may need to worry about rich text markup, and also embedded OLE content, which will complicate matters.

Re: Replace text by Object
Amol_S - Mon Jul 10 00:40:27 EDT 2017

strathglass - Fri Jul 07 09:23:00 EDT 2017

Object o=current
string oTxt=o."Object Text"

Of course the work is easy if it is just plain text.

But you may need to worry about rich text markup, and also embedded OLE content, which will complicate matters.

I want that complicated matter, replace text by embedded ole.

Yet struggling with it.

Re: Replace text by Object
HPM2BP - Fri Jul 14 09:57:01 EDT 2017

Hello!

 

This might be a bit brute force, I haven't tested it yet, but it might help. I haven't finished it yet, on Monday I'll continue

Object o = current
Module m = current

string strText = ""

string strReplacer = ""
strReplacer = o."Object Text" ""

int iContains = 0

Buffer buf = create()

for o in m do{
        strText = o."Object Text"
        buf = strText
        iContains = 0
        
        while (iContains != -1){
                strText = o."Object Text"
                buf = strText
                iContains = contains (buf, '\n' , offset)
                
        }
}

 

Re: Replace text by Object
HPM2BP - Mon Jul 17 03:26:19 EDT 2017

Hello!

 

Here's the final code, I'd suggest playing with it a bit in a sandbox, or something like that. I haven't tested is yet, might contain some errors.

Object o = current
Module m = current

string strText = ""

string strReplacer = ""
strReplacer = o."Object Text" ""

int iContains = 0

Buffer buf = create()

for o in m do{
        strText = o."Object Text"
        buf = strText
        iContains = 0
        
        while (iContains != -1){
                strText = o."Object Text"
                buf = strText
                iContains = contains (buf, "test" , 0)
                if (iContains != -1){
                        strText = strText[0:iContains-1] "" strReplacer "" strText[iContains+4:] ""
                        o."Object Text" = strText ""
                }
        }
}

ack "all done"